home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / oper_sys / emerald / emrldsys.lha / Kernel / SigHandling / emPause.ca next >
Encoding:
Text File  |  1990-08-17  |  2.3 KB  |  94 lines

  1. /*
  2.  * Routine to narrow the gap in losing signals.  (Makes checking task queue
  3.  * atomic).  The method is due to Eric Jul, April 1986.
  4.  *
  5.  *        >>> WARNING <<<
  6.  * As any dolt can see, these routines are EXTREMELY machine dependent.
  7.  * Be very careful what you do with them.  This code must be run through
  8.  * the C-preprocessor (/lib/cpp) in order to work. Note the use of
  9.  * C-style comments.
  10.  *
  11.  * First the machine independent stuff.
  12.  */
  13.         .globl  _dontPause
  14.         .globl  _reallyPause
  15.         .globl  _emPause
  16.         .globl  _shouldPause
  17. /*
  18.  * Now the VAX specific part.
  19.  *
  20.  * When no task is in the EmKernel task queue, _shouldPause is set to
  21.  * _reallyPause, so that a SIGPAUSE Unix system call will take place, causing
  22.  * the EmKernel to pause until a Unix signal is received.  When the task
  23.  * queue becomes non-empty, _shouldPause is set to _dontPause, so that
  24.  * essentially the operation of the emPause routine is a NOP (entry vector
  25.  * 132).
  26.  */
  27. #if defined(vax)
  28.     /* Unix SIGPAUSE entry vector */
  29.     .set    SIGPAUSE, 111
  30.         .data
  31.  
  32.         .align  2
  33. _dontPause:
  34.         ret
  35.         ret
  36.         ret
  37.         ret
  38.         .long   0
  39.         .long   0
  40.  
  41.         .align  2
  42. _reallyPause:
  43.     chmk    $SIGPAUSE
  44.         ret
  45.         .long 0
  46.         .long 0
  47.  
  48.         .align  2
  49. _shouldPause:
  50.     chmk    $SIGPAUSE
  51.         ret
  52.         .long   0
  53.  
  54.     .text
  55.     .align    2
  56. /*
  57.  * We are passed one parameter (usually 0) which represents
  58.  * the signals which will NOT wake us up.
  59.  */
  60. _emPause:
  61.     .word    0x0000
  62.         jmp     _shouldPause
  63.         ret
  64. #endif
  65. /*
  66.  * Now the SUN specific part.  Note that this uses a very
  67.  * different mechanism to achieve its aims.
  68.  *
  69.  * When no task is in the Kernel task queue, _shouldPause is set to
  70.  * _reallyPause, so that a PAUSE Unix system call will take place, causing
  71.  * the Kernel to pause until a Unix signal is received.  When the task
  72.  * queue becomes non-empty, _shouldPause is set to _dontPause, so that
  73.  * essentially the operation of the emPause routine is a NOP.  (This is
  74.  * self-modifying code).
  75.  */
  76. #if defined(sun)
  77. PAUSE = 111                     | Unix system call code
  78.  
  79.         .even
  80.         .data                   | put this code in data region so that 
  81.                                 | we can make it self modifying
  82.  
  83. _dontPause:
  84.         addql #4,sp
  85. _reallyPause:
  86.         trap  #0
  87.  
  88. _emPause:
  89.         pea   PAUSE
  90. _shouldPause:
  91.         trap  #0
  92.         rts
  93. #endif
  94.